using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace PageDraw
{
    public abstract class ToolObject
    {
        protected DrawObject drawObject;

        public virtual void MouseDoubleClick(DrawArea drawArea, MouseEventArgs e)
        { 

        }

        public virtual void MouseDown(DrawArea drawArea, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                drawArea.AddDrawObject(drawObject);
                drawArea.SetPropGridSelectedObject(drawObject);
            }
        }

        public virtual void MouseMove(DrawArea drawArea, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                int dx = e.X - drawObject.X;
                int dy = e.Y - drawObject.Y;
                if (dx <= 0 || dy <= 0)
                {
                    return;
                }
                drawObject.Width = dx;
                drawObject.Height = dy;
                drawArea.Refresh();
                drawArea.SetPropGridSelectedObject(drawObject);
            }
        }

        public virtual void MouseUp(DrawArea drawArea, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                drawObject = null;
            }
        }
    }
}
